import org.junit.Test;
import wujinye.com.constant.Const;
import wujinye.com.controller.login.LoginServlet;
import wujinye.com.dao.*;
import wujinye.com.model.User;
import wujinye.com.service.ArticleService;
import wujinye.com.service.MeetService;
import wujinye.com.service.UserService;
import wujinye.com.service.impl.ArticleServiceImpl;
import wujinye.com.service.impl.MeetServiceImpl;
import wujinye.com.service.impl.UserServiceImpl;
import wujinye.com.utils.EmailUtil;
import wujinye.com.utils.MailUtil;
import wujinye.com.utils.StrUtil;

import javax.mail.MessagingException;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

public class Demo1 {


    @Test
    public void method1() {
        System.out.println("Hello");
    }

    @Test
    public void method2() {
        LoginServlet loginServlet = new LoginServlet();
        System.out.println("Hello");
    }

    @Test
    public void method3() {
        UserService userService = new UserServiceImpl();
        User u = new User();
        u.setEmail("123@qq.com");
        u.setPassword("123");
        u.setUsername("haha");
        //userService.addUser(u);
    }

    @Test
    public void method4() {
        System.out.println(Math.random());
        System.out.println(StrUtil.randomCode());
    }

    @Test
    public void method5() {
        UserInfoDao userInfoDao = new UserInfoDao();
        List<Map<String, Object>> userList = userInfoDao.findUserList(1, null, 1);
        for (Map<String, Object> map : userList) {
            System.out.println(map.get("id"));
        }
    }

    @Test
    public void method6() {
        FavoriteDao favoriteDao = new FavoriteDao();
        favoriteDao.isCollect(2,1);
    }

    @Test
    public void method7() {
        ArticleService articleService = new ArticleServiceImpl();
        articleService.addArticle(1,"1","1");
    }


    @Test
    public void method8() {
        UserService userService = new UserServiceImpl();
        List<Map<String,Object>> list = userService.getUserCount();
        for (Map<String,Object> obj: list) {
            System.out.println(obj.toString());
        }
    }


    @Test
    public void method9() {
        ConferenceDao conferenceDao = new ConferenceDao();
        conferenceDao.findMeetingList(null,null,1);
    }

    @Test
    public void method10() {
        MeetService meetService = new MeetServiceImpl();
        meetService.findMeetingList(null,null,1);
    }

    @Test
    public void method11() {
        ConJoinDao conJoinDao = new ConJoinDao();
        System.out.println(conJoinDao.getTotalAbsence(10));
    }

    @Test
    public void method12() {
        ConJoinDao conJoinDao = new ConJoinDao();
        Object[] come = conJoinDao.isCome(3, 1);
        System.out.println(come[0]);
    }

    @Test
    public void method13() {
        MeetService meetService = new MeetServiceImpl();
        meetService.addMeeting(1,"2","哈哈","hahaha","23:00");
    }

    @Test
    public void sendEmail(){

//                《小标交友》重置密码
        String title = "Small Bell Make Friends reset password";
        String code = StrUtil.randomCode();
        // 您的验证码:
        String content = "Your verification code is：" + code;
        System.out.println("title："+title);
        System.out.println("content："+content);
        try {
            MailUtil.send("2356885399@qq.com", title, content, MailUtil.UNICODE);
        } catch (MessagingException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void test(){
        String title = "《小标交友》重置密码";
        String code = StrUtil.randomCode();
        // Your verification code is
        String content = "您的验证码:" + code;
        System.out.println("title："+title);
        System.out.println("content："+content);
        try {
            EmailUtil.sendMail("2356885399@qq.com", title, content);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
